﻿using System;
using System.ComponentModel;
using Gizmox.WebGUI.Common.Resources;
using Gizmox.WebGUI.Forms;

namespace CoCoon.Forms.Ribbon
{
        [Serializable]
        public class RibbonBarCheckButtonItem : RibbonBarCheckBoxItem
        {

            public CheckBox CheckBox { get; private set; }

            protected override Control CreateControl()
            {
                CheckBox = new CheckBox();
                //checkBox.CheckedChanged += new EventHandler(this.OnCheckedChanged);
                CheckBox.Appearance = Gizmox.WebGUI.Forms.Appearance.Button;
                CheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter;
                CheckBox.ImageSize = new System.Drawing.Size(32, 32);
                CheckBox.Size = new System.Drawing.Size(66, 66);
                CheckBox.TabIndex = 1;
                CheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                CheckBox.TextImageRelation = Gizmox.WebGUI.Forms.TextImageRelation.ImageAboveText;
                CheckBox.BorderStyle = BorderStyle.None;
                return (Control)CheckBox;
            }

            //private void OnCheckedChanged(object sender, EventArgs e)
            //{
            //    if (this.RibbonBar == null)
            //        return;
            //    this.RibbonBar.OnCheckedChanged(this);
            //}

            public bool Checked { get { return CheckBox.Checked; }
                set { CheckBox.Checked = value; }
            }

            [DefaultValue(null)]
            public virtual ResourceHandle Image
            {
                get
                {
                    return this.CheckBox.Image;
                }
                set
                {
                    this.CheckBox.Image = value;
                }
            }
        }
    }
